

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>nrgpy.convert.convert_rld &mdash; nrgpy 0.10.19 documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html" class="icon icon-home"> nrgpy
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">nrgpy</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../../index.html">Module code</a> &raquo;</li>
        
      <li>nrgpy.convert.convert_rld</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for nrgpy.convert.convert_rld</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">subprocess</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">from</span> <span class="nn">nrgpy.api.convert</span> <span class="kn">import</span> <span class="n">nrg_api_convert</span>
<span class="kn">from</span> <span class="nn">nrgpy.utils.utilities</span> <span class="kn">import</span> <span class="n">check_platform</span><span class="p">,</span> <span class="n">windows_folder_path</span><span class="p">,</span> <span class="n">affirm_directory</span><span class="p">,</span> <span class="n">count_files</span>


<div class="viewcode-block" id="local"><a class="viewcode-back" href="../../../nrgpy.convert.html#nrgpy.convert.convert_rld.local">[docs]</a><span class="k">class</span> <span class="nc">local</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;For handling NRG SymphoniePRO Data Logger raw data files in the *.rld format.</span>

<span class="sd">    This method uses locally installed SymphoniePRO Desktop software to convert *.rld files to txt format (tab-delimited-text).</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    rld_dir : str, optional</span>
<span class="sd">        specify directory. Note for unc values, you</span>
<span class="sd">        will need to escape all forward slashes, e.g.</span>
<span class="sd">        rld_dir = &quot;\\\\sol\\techsupport\\data\\&quot;</span>
<span class="sd">        or use the r&#39;\\path\to\dir&#39; approach</span>
<span class="sd">    out_dir : str, optional</span>
<span class="sd">        see note for rld_dir.</span>
<span class="sd">    encryption_pass : str</span>
<span class="sd">        specify data encryption password if logger is set up for that.</span>
<span class="sd">    hex_key : str</span>
<span class="sd">        specify if using hex data encryption key</span>
<span class="sd">    sympro_path : str</span>
<span class="sd">        default is &quot;C:\Program Files (x86)\Renewable NRG Systems\SymPRO Desktop\SymPRODesktop.exe&quot;</span>
<span class="sd">    process_type : str</span>
<span class="sd">        [convert], or import</span>
<span class="sd">    convert_type : str</span>
<span class="sd">        &#39;meas&#39;, alternately specify &#39;comm&#39;, &#39;diag&#39;, &#39;sample&#39;, or &#39;events&#39;</span>
<span class="sd">    nec : str</span>
<span class="sd">        path to nec file</span>
<span class="sd">    site_filter : str</span>
<span class="sd">        specify part or all of the file you&#39;d like to filter on, like site_filter=&#39;123456_2018-09&#39;</span>
<span class="sd">        would filter on site 123456 and only the month of September in 2018.</span>
<span class="sd">    site_file : bool or str</span>
<span class="sd">        set to True to use local ndb site file, or set to path to an alternate ndb site file</span>

<span class="sd">    Examples</span>
<span class="sd">    --------</span>
<span class="sd">    Convert a folder of RLD files to Text with SymphoniePRO Desktop Software</span>

<span class="sd">    &gt;&gt;&gt; from nrgpy.convert_rld import local</span>
<span class="sd">    &gt;&gt;&gt; converter = local(</span>
<span class="sd">            rld_dir=&#39;/path/to/rld/files&#39;,</span>
<span class="sd">            out_dir=/path/to/txt/outputs,</span>
<span class="sd">            file_filter=&#39;123456_2020-01&#39;, # for files from January 2020</span>
<span class="sd">        )</span>
<span class="sd">    &gt;&gt;&gt; converter.convert()</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">rld_dir</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">out_dir</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">encryption_pass</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">hex_key</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
                 <span class="n">sympro_path</span><span class="o">=</span><span class="sa">r</span><span class="s1">&#39;&quot;C:/Program Files (x86)/Renewable NRG Systems/SymPRO Desktop/SymPRODesktop.exe&quot;&#39;</span><span class="p">,</span>
                 <span class="n">process_type</span><span class="o">=</span><span class="s1">&#39;convert&#39;</span><span class="p">,</span> <span class="n">convert_type</span><span class="o">=</span><span class="s1">&#39;meas&#39;</span><span class="p">,</span> <span class="n">nec</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">site_filter</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">site_file</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">rld_dir</span> <span class="o">=</span> <span class="n">windows_folder_path</span><span class="p">(</span><span class="n">rld_dir</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span> <span class="o">=</span> <span class="n">windows_folder_path</span><span class="p">(</span><span class="n">out_dir</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">encryption_pass</span> <span class="o">=</span> <span class="n">encryption_pass</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">hex_key</span> <span class="o">=</span> <span class="n">hex_key</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sympro_path</span> <span class="o">=</span> <span class="n">sympro_path</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">process_type</span> <span class="o">=</span> <span class="n">process_type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">convert_type</span> <span class="o">=</span> <span class="n">convert_type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nec</span> <span class="o">=</span> <span class="n">nec</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">site_filter</span> <span class="o">=</span> <span class="n">site_filter</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">site_file</span> <span class="o">=</span> <span class="n">site_file</span>

        <span class="k">if</span> <span class="s1">&#39;file_filter&#39;</span> <span class="ow">in</span> <span class="n">kwargs</span> <span class="ow">and</span> <span class="n">site_filter</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;file_filter&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_filter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span>

        <span class="k">if</span> <span class="n">check_platform</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;win32&#39;</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">filename</span><span class="p">:</span>
                <span class="n">affirm_directory</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">single_file</span><span class="p">(</span><span class="n">filepath</span><span class="o">=</span><span class="n">filename</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;&quot;</span>
<span class="s2">            convert_rld.local() method ONLY compatible with Windows OS.</span>
<span class="s2">            Please use convert_rld.nrg_convert_api() method instead.</span>
<span class="s2">            &quot;&quot;&quot;</span><span class="p">)</span>

<div class="viewcode-block" id="local.directory"><a class="viewcode-back" href="../../../nrgpy.convert.html#nrgpy.convert.convert_rld.local.directory">[docs]</a>    <span class="k">def</span> <span class="nf">directory</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;processes all rld files in self.rld_dir, outputs to txt files to out_dir&quot;&quot;&quot;</span>
        <span class="n">affirm_directory</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">encryption_pass</span><span class="p">:</span>
                <span class="n">encryption</span> <span class="o">=</span> <span class="s1">&#39;/pass &quot;</span><span class="si">{0}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">encryption_pass</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">encryption</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;could not parse encryption_pass&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">hex_key</span><span class="p">:</span>
                <span class="n">encryption_key</span> <span class="o">=</span> <span class="s1">&#39;/key &quot;</span><span class="si">{0}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">hex_key</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">encryption_key</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;could not parse hex_key&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">nec</span><span class="p">:</span>
                <span class="n">nec</span> <span class="o">=</span> <span class="s1">&#39;/config &quot;</span><span class="si">{0}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nec</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">nec</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;could not parse encryption_pass&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_file</span><span class="p">:</span>
                <span class="n">site_file</span> <span class="o">=</span> <span class="s1">&#39;/site &#39;</span>
            <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_file</span><span class="p">:</span>
                <span class="n">site_file</span> <span class="o">=</span> <span class="s1">&#39;/site &quot;</span><span class="si">{0}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">site_file</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">site_file</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;could not parse encryption_pass&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">rld_count</span> <span class="o">=</span> <span class="n">count_files</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rld_dir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_filter</span><span class="p">,</span> <span class="s1">&#39;rld&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">start_time</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">Converting </span><span class="si">{0}</span><span class="s1"> files from </span><span class="si">{1}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">rld_count</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rld_dir</span><span class="p">))</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Saving outputs to </span><span class="si">{0}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span><span class="p">))</span>

            <span class="n">cmd</span> <span class="o">=</span> <span class="p">[</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">sympro_path</span><span class="p">,</span>
                <span class="s2">&quot;/cmd&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">process_type</span><span class="p">,</span>
                <span class="s2">&quot;/file&quot;</span><span class="p">,</span> <span class="s1">&#39;&quot;&#39;</span><span class="o">+</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">rld_dir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_filter</span><span class="p">])</span><span class="o">+</span><span class="s1">&#39;*.rld&quot;&#39;</span><span class="p">,</span>
                <span class="n">encryption</span><span class="p">,</span>
                <span class="n">encryption_key</span><span class="p">,</span>
                <span class="n">nec</span><span class="p">,</span>
                <span class="n">site_file</span><span class="p">,</span>
                <span class="s2">&quot;/type&quot;</span><span class="p">,</span> <span class="s1">&#39;&quot;&#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">convert_type</span><span class="o">+</span><span class="s1">&#39;&quot;&#39;</span><span class="p">,</span>
                <span class="s2">&quot;/outputdir&quot;</span><span class="p">,</span> <span class="s1">&#39;&quot;&#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">+</span><span class="s1">&#39;&quot;&#39;</span>
            <span class="p">]</span>

            <span class="c1"># print(&#39;\nUsing command line script:\n{}&#39;.format(&quot; &quot;.join(cmd)))</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">cmd</span> <span class="o">=</span> <span class="n">cmd</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>

            <span class="n">subprocess</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">cmd</span><span class="p">),</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">convert_time</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="p">)</span>

            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">TXT files saved in </span><span class="si">{0}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span><span class="p">))</span>

            <span class="n">txt_count</span> <span class="o">=</span> <span class="n">count_files</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_filter</span><span class="p">,</span> <span class="s1">&#39;txt&#39;</span><span class="p">,</span> <span class="n">start_time</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">start_time</span><span class="p">)</span>
            <span class="n">log_count</span><span class="p">,</span> <span class="n">log_files</span> <span class="o">=</span> <span class="n">count_files</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_filter</span><span class="p">,</span> <span class="s1">&#39;log&#39;</span><span class="p">,</span> <span class="n">show_files</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">start_time</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">start_time</span><span class="p">)</span>

            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;RLDs in    : </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">rld_count</span><span class="p">))</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;TXTs out   : </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">txt_count</span><span class="p">))</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;LOGs out   : </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">log_count</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">log_files</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Log files created:&#39;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">_filename</span> <span class="ow">in</span> <span class="n">log_files</span><span class="p">:</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\t</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">_filename</span><span class="p">))</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;----------------</span><span class="se">\n</span><span class="s1">Difference : </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">rld_count</span> <span class="o">-</span> <span class="p">(</span><span class="n">txt_count</span> <span class="o">+</span> <span class="n">log_count</span><span class="p">)))</span>

        <span class="k">except</span> <span class="ne">FileNotFoundError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;&quot;</span>
<span class="s2">                  No instance of SymphoniePRO Desktop Application found.</span>

<span class="s2">                  Please follow the link below to download and install this software:</span>
<span class="s2">                  https://www.nrgsystems.com/support/product-support/software/symphoniepro-desktop-application</span>

<span class="s2">                  &quot;&quot;&quot;</span><span class="p">)</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Unable to process files in directory&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="local.convert"><a class="viewcode-back" href="../../../nrgpy.convert.html#nrgpy.convert.convert_rld.local.convert">[docs]</a>    <span class="k">def</span> <span class="nf">convert</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">directory</span><span class="p">()</span></div>

<div class="viewcode-block" id="local.process"><a class="viewcode-back" href="../../../nrgpy.convert.html#nrgpy.convert.convert_rld.local.process">[docs]</a>    <span class="k">def</span> <span class="nf">process</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">directory</span><span class="p">()</span></div>

<div class="viewcode-block" id="local.rename_rlds"><a class="viewcode-back" href="../../../nrgpy.convert.html#nrgpy.convert.convert_rld.local.rename_rlds">[docs]</a>    <span class="k">def</span> <span class="nf">rename_rlds</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;uses SymPRO utility NrgRldSiteSerialRename.exe to rename files with site number and logger serial number.</span>

<span class="sd">        This function is only compatible with Windows&gt;=7 AND</span>
<span class="sd">        a local installation of SymphoniePRO Desktop software</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">renamer_path</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;renamer_path&#39;</span><span class="p">,</span> <span class="sa">r</span><span class="s2">&quot;C:/Program Files (x86)/Renewable NRG Systems/SymPRO Desktop/Default Application Files/Utilities/NrgRldSiteSerialRename.exe&quot;</span><span class="p">)</span>

            <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rld_dir</span><span class="p">):</span>

                <span class="n">filepath</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">rld_dir</span> <span class="o">+</span> <span class="n">f</span>

                <span class="k">if</span> <span class="n">f</span><span class="p">[</span><span class="o">-</span><span class="mi">4</span><span class="p">:]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">==</span><span class="s2">&quot;.rld&quot;</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_filter</span> <span class="ow">in</span> <span class="n">f</span><span class="p">:</span>
                    <span class="n">rename_cmd</span> <span class="o">=</span> <span class="p">[</span><span class="n">renamer_path</span><span class="p">,</span> <span class="s1">&#39;&quot;&#39;</span><span class="o">+</span><span class="n">filepath</span><span class="o">+</span><span class="s1">&#39;&quot;&#39;</span><span class="p">]</span>

                    <span class="k">try</span><span class="p">:</span>
                        <span class="n">subprocess</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">rename_cmd</span><span class="p">),</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span>
                    <span class="k">except</span><span class="p">:</span>
                        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Unable to rename </span><span class="si">{0}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">f</span><span class="p">))</span>
                        <span class="k">pass</span>

                <span class="k">else</span><span class="p">:</span>
                    <span class="k">pass</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Could not rename files&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="local.single_file"><a class="viewcode-back" href="../../../nrgpy.convert.html#nrgpy.convert.convert_rld.local.single_file">[docs]</a>    <span class="k">def</span> <span class="nf">single_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filepath</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filepath</span> <span class="o">=</span> <span class="n">filepath</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">,</span><span class="s1">&#39;</span><span class="se">\\</span><span class="s1">&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">encryption_pass</span><span class="p">:</span>
                <span class="n">encryption</span> <span class="o">=</span> <span class="s1">&#39;/pass &quot;</span><span class="si">{0}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">encryption_pass</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">encryption</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;could not parse encryption_pass&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">hex_key</span><span class="p">:</span>
                <span class="n">encryption_key</span> <span class="o">=</span> <span class="s1">&#39;/key &quot;</span><span class="si">{0}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">hex_key</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">encryption_key</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;could not parse hex_key&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">nec</span><span class="p">:</span>
                <span class="n">nec</span> <span class="o">=</span> <span class="s1">&#39;/config &quot;</span><span class="si">{0}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nec</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">nec</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;could not get nec file&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_file</span><span class="p">:</span>
                <span class="n">site_file</span> <span class="o">=</span> <span class="s1">&#39;/site &quot;</span><span class="si">{0}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">site_file</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">site_file</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;could not get site file&#39;</span><span class="p">)</span>

        <span class="n">cmd</span> <span class="o">=</span> <span class="p">[</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sympro_path</span><span class="p">,</span>
            <span class="s2">&quot;/cmd&quot;</span><span class="p">,</span> <span class="s2">&quot;convert&quot;</span><span class="p">,</span>
            <span class="s2">&quot;/file&quot;</span><span class="p">,</span> <span class="s1">&#39;&quot;&#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">filepath</span><span class="o">+</span><span class="s1">&#39;&quot;&#39;</span><span class="p">,</span>
            <span class="n">encryption</span><span class="p">,</span>
            <span class="n">encryption_key</span><span class="p">,</span>
            <span class="n">nec</span><span class="p">,</span>
            <span class="n">site_file</span><span class="p">,</span>
            <span class="s2">&quot;/type&quot;</span><span class="p">,</span> <span class="s1">&#39;&quot;&#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">convert_type</span><span class="o">+</span><span class="s1">&#39;&quot;&#39;</span><span class="p">,</span>
            <span class="s2">&quot;/outputdir&quot;</span><span class="p">,</span> <span class="s1">&#39;&quot;&#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">out_dir</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">+</span><span class="s1">&#39;&quot;&#39;</span>
        <span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cmd</span> <span class="o">=</span> <span class="n">cmd</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{0}</span><span class="s2"> ... </span><span class="se">\t\t</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">filepath</span><span class="p">),</span> <span class="n">end</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
            <span class="n">subprocess</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">cmd</span><span class="p">),</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[DONE]&quot;</span><span class="p">)</span>

        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n\t</span><span class="s2"> processing </span><span class="si">{0}</span><span class="s2"> [FAILED]&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">filepath</span><span class="p">))</span>
            <span class="k">pass</span>

        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Queue processed</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span></div></div>


<span class="n">nrg_convert_api</span> <span class="o">=</span> <span class="n">nrg_api_convert</span>
</pre></div>

           </div>
           
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2020, NRG Systems, Technical Services.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>